home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SPX20.ZIP / SPX_DOC.ZIP / SPX_KEY.DOC < prev    next >
Text File  |  1993-09-15  |  4KB  |  94 lines

  1. { SPX Library Version 2.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.   SPX_KEY is the keyboard handling unit.  It takes over the keyboard
  4. interrupt to allow for reading of multiple keys at the same time.
  5.  
  6.   The (boolean) flags below tells if that key is pressed.  If the flag
  7. is TRUE then a user has key down.  FALSE means the key is not pressed.
  8.  
  9.   Look at the following IF-THEN Pascal code:
  10.  
  11.   if enter and esc and space and lshft
  12.     then { Some one is pressing the Enter, Esc, Space, AND, Left Shift key }
  13.  
  14.   There is also a custom array flag build specfically for one/two player
  15.   games.
  16.  
  17.       NP[1..9,1..2] of boolean;
  18.  
  19.   Think of the first index as a key grid like the numeric key pad and
  20.   the second index as which player then your program can use
  21.  
  22.        NP[n,1]            Direction           NP[n,2]
  23.      Player  One                            Player  Two
  24.     ┌───┬───┬───┐       ┌───┬───┬───┐      ┌───┬───┬───┐
  25.     │n=7│n=8│n=9│       │ \ │/|\│ / │      │n=7│n=8│n=9│
  26.     ├───┼───┼───┤       ├───┼───┼───┤      ├───┼───┼───┤
  27.     │n=4│n=5│n=6│       │<- │   │ ->│      │n=4│n=5│n=6│
  28.     ├───┼───┼───┤       ├───┼───┼───┤      ├───┼───┼───┤
  29.     │n=1│n=2│n=3│       │ / │\|/│ \ │      │n=1│n=2│n=3│
  30.     └───┴───┴───┘       └───┴───┴───┘      └───┴───┴───┘
  31.  
  32.  
  33.     You can use NP[8,x] as the up key, NP[6,x] as the right key etc.
  34.  
  35.     e.g.
  36.  
  37.     if np[6,1]
  38.       then { Move player 1 to the right }
  39.     if np[1,2]
  40.       then { Move player 2 left and down }
  41.  
  42. ───────────────────────────────────────────────────────────────────────────
  43.   cleared,                                    { TRUE - if int is disabled }
  44.   cold,                                       { TRUE - call old int }
  45.   plus,                                       { plus key pressed }
  46.   minus,                                      { minus key pressed }
  47.   lshft,rshft,                                { shift keys pressed }
  48.   space,                                      { space key pressed }
  49.   bspc,                                       { backspace pressed }
  50.   esc,                                        { esc pressed }
  51.   ctrl,                                       { a ctrl key is pressed }
  52.   alt,                                        { an alt key is pressed }
  53.   enter            : boolean;                 { enter pressed }
  54.  
  55.   portb            : byte;  { returns the current scan code from the }
  56.                             { keyboard, if the hi-bit is set then portb }
  57.                             { indicates that the key has been released }
  58.  
  59. ───────────────────────────────────────────────────────────────────────────
  60. procedure clearbuffer;
  61.  
  62.    Waits until no key is pressed
  63.  
  64. ───────────────────────────────────────────────────────────────────────────
  65. procedure clearkeyint;
  66.  
  67.    Restores the old keyboard interrupt
  68.  
  69. ───────────────────────────────────────────────────────────────────────────
  70. procedure installkeyint;
  71.  
  72.    Installs the SPX_KEY keyboard interrupt
  73.  
  74.    Use with clearkeyint.  To install and remove the interrupt multiple
  75. times during the program.
  76.  
  77. ───────────────────────────────────────────────────────────────────────────
  78. function anykey:boolean;
  79.  
  80.    Returns TRUE if any key is pressed
  81.  
  82. ───────────────────────────────────────────────────────────────────────────
  83. procedure cli; inline($fa);
  84.  
  85.   Disable maskable interrupts
  86.  
  87. ───────────────────────────────────────────────────────────────────────────
  88. procedure sti; inline($fb);
  89.  
  90.   Enable maskable interrupts
  91.  
  92. ───────────────────────────────────────────────────────────────────────────
  93.  
  94.